#include "..\\GameEngine\\GameEngine.h"
#include "BaseMenu.h"

class MainMenu : public BaseMenu, public IListener<ClickEventArgs>
{

    Button* btnSinglePlayer;
    Button* btnMultiPlayer;    
    Button* btnScores;
    Button* btnAuthors;
    Button* btnExit;

public:

    virtual void IListener<ClickEventArgs>::operator()(TGameObject* sender, ClickEventArgs* args)
    {
        //IListener<ClickEventArgs>* btnClicked = dynamic_cast<IListener<ClickEventArgs>*>(sender);
        if (sender == btnSinglePlayer)
        {
            GameState::Switch("SinglePlayer");
        }
        else if (sender == btnMultiPlayer) 
        {
            GameState::Switch("NetMenu");
        }
        else if (sender == btnScores)
        {

        }
        else if (sender == btnAuthors)
        {

        }
        else if (sender == btnExit){

        }      
    }

    virtual void Initialize() 
    {          
        BaseMenu::Initialize();

        btnSinglePlayer = CreateButton("Single player", 0);  
        btnMultiPlayer  = CreateButton("Multi player", 1); 
        btnScores       = CreateButton("Scores", 2); 
        btnAuthors      = CreateButton("Authors", 3); 
        btnExit         = CreateButton("Exit", 4); 
        
        Button* arr[] = {btnSinglePlayer, btnMultiPlayer, btnScores, btnAuthors, btnExit};

        for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
        {
            arr[i]->SetListener(this);            
        }
    }

    virtual void Deinitialize() 
    {
        BaseMenu::Deinitialize();

        GameEngine::RemoveObject(btnSinglePlayer);
        GameEngine::RemoveObject(btnMultiPlayer);
        GameEngine::RemoveObject(btnScores);
        GameEngine::RemoveObject(btnAuthors);
        GameEngine::RemoveObject(btnExit);        
    }

    virtual void DoAction() 
    {

    }

    virtual void OnDraw() 
    {

    }

};